// $codepro.audit.disable com.instantiations.assist.eclipse.analysis.avoidPackageScopeAuditRule, numericLiterals, spellCheckIdentifiers, questionableName, spellCheckComments, spellCheckStringLiterals, temporaryObjectCreation, unnecessaryImport, declareAsInterface, spaceAroundPeriods, variableShouldBeFinal
/**
 * Package gui
 */
package teamrocket.gui; // $codepro.audit.disable packagePrefixNamingConvention

import java.awt.EventQueue;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.ImageIcon;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JTabbedPane;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JList;

import teamrocket.db.DBWrapper;
import teamrocket.domain.Appointment;
import teamrocket.domain.Doctor;
import teamrocket.domain.DoctorsOrders;
import teamrocket.domain.Patient;
import teamrocket.domain.PatientChart;
import teamrocket.domain.PatientInvoice;
import teamrocket.domain.TreatmentRecord;
import teamrocket.domain.User;

import org.jdesktop.beansbinding.AutoBinding.UpdateStrategy;
import org.jdesktop.swingbinding.JComboBoxBinding;
import org.jdesktop.swingbinding.JListBinding;
import org.jdesktop.swingbinding.SwingBindings;
import org.jdesktop.beansbinding.ELProperty;
import javax.swing.JComboBox;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTextArea;
import javax.swing.DefaultComboBoxModel;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.JSplitPane;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Image;
import java.awt.Insets;
import javax.swing.border.LineBorder;
import java.awt.Color;
import org.jdesktop.beansbinding.BeanProperty;
import org.jfree.chart.ChartPanel;

import javax.swing.JScrollPane;
import javax.swing.DropMode;

/**
 * @author James Zhang, Juan Llanes, Stephen Tapper, Will Barr
 * @version 1.0
 */
public class MainFrame extends JFrame {

	/**
	 * Field contentPane.
	 */
	private JPanel contentPane;

	/**
	 * Field tbSearch.
	 */
	private JTextField tbSearch;
	
	/**
	 * Field patients.
	 */
	private List<Patient> patients;
	
	/**
	 * Field appsPatient.
	 */
	private List<Appointment> appsPatient;
	
	/**
	 * Field apps.
	 */
	private List<Appointment> apps;
	
	/**
	 * Field trs.
	 */
	private List<TreatmentRecord> trs;
	
	/**
	 * Field users.
	 */
	private List<User> users; // $codepro.audit.disable com.instantiations.assist.eclipse.analysis.avoidSimilarNames
	
	/**
	 * Field patientChart.
	 */
	ChartPanel patientChart;
	
	/**
	 * Field doctors.
	 */
	List<User> doctors;
	
	/**
	 * Field cmbDoctor.
	 */
	private JComboBox cmbDoctor;
	
	/**
	 * Field cmbDay.
	 */
	private JComboBox cmbDay;
	
	/**
	 * Field cmbMonth.
	 */
	private JComboBox cmbMonth;
	
	/**
	 * Field cmbYear.
	 */
	private JComboBox cmbYear;
		
	/**
	 * Field lstPatients.
	 */
	private JList lstPatients;
	
	/**
	 * Field lstTRs.
	 */
	private JList lstTRs;
	
	/**
	 * Field lstMedical.
	 */
	private JList lstMedical;
	
	/**
	 * Field lstUsers.
	 */
	private JList lstUsers;
	
	/**
	 * Field tbReason.
	 */
	private JTextField tbReason;
	
	/**
	 * Field tbFirst.
	 */
	private JTextField tbFirst;
	
	/**
	 * Field tbLast.
	 */
	private JTextField tbLast;
	
	/**
	 * Field tbUsername.
	 */
	private JTextField tbUsername;
	
	/**
	 * Field tbPassword.
	 */
	private JTextField tbPassword;
	
	/**
	 * Field tbMonth.
	 */
	private JTextField tbMonth;
	
	/**
	 * Field cbUserType.
	 */
	private JComboBox cbUserType;
	
	/**
	 * Field pnlPatientAppointments.
	 */
	JPanel pnlPatientAppointments;
	
	/**
	 * Field pnlHistory.
	 */
	JPanel pnlHistory;
	
	/**
	 * Field pnlPatients.
	 */
	JPanel pnlPatients;
	
	/**
	 * Field panel.
	 */
	JPanel panel;
	
	/**
	 * Field pnlReports.
	 */
	JPanel pnlReports;
	
	/**
	 * Field pnlUsers.
	 */
	JPanel pnlUsers;
	
	/**
	 * Field chartPanel.
	 */
	ImagePanel chartPanel;
	
	/**
	 * Field tabbedPane.
	 */
	JTabbedPane tabbedPane;
	
	/**
	 * Field lstAppointments.
	 */
	private JList lstAppointments;
	
	/**
	 * Field lstAppointments2.
	 */
	private JList lstAppointments2;
	
	/**
	 * Field user.
	 */
	private User user;
	
	/**
	 * Field tbHourMin.
	 */
	private JTextField tbHourMin;
	
	/**
	 * Field day.
	 */
	private final List<Integer> day = new ArrayList<Integer>();{
		for (int i = 1; i <= 31; i++) {
			day.add(i);
		}
	}
	
	/**
	 * Field monthsArray.
	 */
	private final String[] monthsArray = {"JANUARY", "FEBRUARY",
			"MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER",
			"OCTOBER", "NOVEMBER", "DECEMBER"};
	
	/**
	 * Field months.
	 */
	private final List<String> months = new ArrayList<String>();{
		for (int i = 0; i < 12; i++){
			months.add(monthsArray[i]);
		}
	}
	
	/**
	 * Field year.
	 */
	private final List<Integer> year = new ArrayList<Integer>();{
		for (int i = 2011; i <= 2015; i++){
			year.add(i);
		}
	}
	
	/**
	 * Launch the application.
	 * @param args String[]
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					final User u = null;
					final MainFrame frame = new MainFrame(u);
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
	
	/**
	 * Method setDefaultValues.
	 */
	private void setDefaultValues() { // $codepro.audit.disable accessorMethodNamingConvention
		patients = Patient.lookupAllPatients();
		final int patientId = user.tryGetPatientId();
		appsPatient = new ArrayList<Appointment>(Appointment.
				getAppointments(patientId)); //problem is here
		apps = new ArrayList<Appointment>(Appointment.
				getAppointmentsAtDate(new Date()));
		trs = TreatmentRecord.getTreatmentRecords(patientId);
		users = User.getUsers();
		doctors = User.lookupAllUsersOfType("d");
	}
	
	/**
	 * Create the frame.
	 * @param loggedUser User
	 */
	public MainFrame(User loggedUser) { // $codepro.audit.disable com.instantiations.assist.eclipse.analysis.audit.rule.effectivejava.constructorsOnlyInvokeFinalMethods

		this.user = loggedUser;
		if (loggedUser == null)return;

		setDefaultValues();
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 730, 742);
		
		final JMenuBar menuBar = new JMenuBar();
		setJMenuBar(menuBar);
		
		final JMenu mnFile = new JMenu("File");
		menuBar.add(mnFile);
		
		final JMenuItem mntmLogout = new JMenuItem("Logout");
		mnFile.add(mntmLogout);
		
		final JMenuItem mntmExitAndLogout = new JMenuItem("Exit and Logout");
		mnFile.add(mntmExitAndLogout);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		tabbedPane = new JTabbedPane(JTabbedPane.TOP); // $codepro.audit.disable staticMemberAccess
		tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
		tabbedPane.setBounds(32, 54, 608, 538);
		contentPane.add(tabbedPane);
		
		pnlPatientAppointments = new JPanel();
		tabbedPane.addTab("Appointments", null, pnlPatientAppointments, null);
		pnlPatientAppointments.setLayout(null);
		
		lstAppointments = new JList();
		lstAppointments.addListSelectionListener(new ListSelectionListener() {
			public void valueChanged(ListSelectionEvent arg0) {
				Appointment newApp = (Appointment)lstAppointments.getSelectedValue();
				tbReason.setText(newApp.getReason());
			
				Date newDate = newApp.getDate();
				
				tbHourMin.setText(newDate.getHours()+":"+newDate.getMinutes());
				
				int newDay = newDate.getDate();
				Iterator<Integer> it = day.iterator();
				int i = 0;
				while(it.hasNext())
				{
					int currentDay = it.next();
					if (newDay == currentDay){
						cmbDay.setSelectedIndex(i);
						break;
					}
					i++;		
				}
				
				
				int newMonth = newDate.getMonth();
				cmbMonth.setSelectedIndex(newMonth);
				
				
				
				int newYear = newDate.getYear()+1900;
				it = year.iterator();
				i = 0;
				while(it.hasNext())
				{
					int current = it.next();
					if (newYear == current){
						cmbYear.setSelectedIndex(i);
						break;
					}
					i++;		
				}
				
			}
		});
		lstAppointments.setBounds(10, 61, 249, 200);
		pnlPatientAppointments.add(lstAppointments);
		
		final JLabel lblMyScheduledAppointments = new
			JLabel("My Scheduled Appointments:");
		lblMyScheduledAppointments.setBounds(10, 38, 249, 14);
		pnlPatientAppointments.add(lblMyScheduledAppointments);
		
		final JButton btnSchedule = new JButton("Schedule");
		btnSchedule.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				final Calendar cal = Calendar.getInstance();
				final int year = (Integer) (cmbYear.getSelectedItem()); 
				final int day = (Integer) (cmbDay.getSelectedItem());
				final String monthStr = (String) (cmbMonth.getSelectedItem());
				int monthInt = 0;
				for (int i = 0; i < monthsArray.length; i++){
					if (monthsArray[i].equalsIgnoreCase(monthStr)){
						monthInt = i;
						break;
					}
				}
				final String[] time = tbHourMin.getText().split(":");
				final int hour = Integer.parseInt(time[0]); // $codepro.audit.disable handleNumericParsingErrors
				final int min = Integer.parseInt(time[1]); // $codepro.audit.disable handleNumericParsingErrors
				
				cal.set(year, monthInt, day, hour, min, 0);
				final Date newDate = cal.getTime();
				
				final Appointment newApp = new Appointment(newDate,
						tbReason.getText(), user.tryGetPatientId(),
						((User) (cmbDoctor.getSelectedItem())).getUID());
				newApp.create(); // $codepro.audit.disable com.instantiations.assist.eclipse.analysis.unusedReturnValue
				
				appsPatient.add(newApp);
				resetNewAppFields();
				rebindApps();
				
			}
		});
		btnSchedule.setBounds(365, 272, 89, 23);
		pnlPatientAppointments.add(btnSchedule);

		final JLabel lblScheduleNewAppontment =
			new JLabel("Schedule New Appointment:");
		lblScheduleNewAppontment.setBounds(365, 38, 187, 14);
		pnlPatientAppointments.add(lblScheduleNewAppontment);
				
				final JLabel lblReasonForAppointment =
					new JLabel("Reason for Appointment:");
				lblReasonForAppointment.setBounds(365, 220, 170, 14);
				pnlPatientAppointments.add(lblReasonForAppointment);
				
				tbReason = new JTextField();
				tbReason.setColumns(10);
				tbReason.setBounds(365, 238, 172, 23);
				pnlPatientAppointments.add(tbReason);
				
						final JLabel lblDesiredDoctor =
							new JLabel("Desired Doctor:");
						lblDesiredDoctor.setBounds(365, 175, 170, 14);
						pnlPatientAppointments.add(lblDesiredDoctor);
						
						cmbDoctor = new JComboBox();
						cmbDoctor.setBounds(365, 189, 172, 20);
						pnlPatientAppointments.add(cmbDoctor);
						
						final JLabel label_12 = new JLabel("Time:");
						label_12.setBounds(366, 61, 46, 14);
						pnlPatientAppointments.add(label_12);
						
						tbHourMin = new JTextField();
						tbHourMin.setColumns(10);
						tbHourMin.setBounds(407, 61, 130, 20);
						pnlPatientAppointments.add(tbHourMin);
						
						cmbDay = new JComboBox();
						cmbDay.setBounds(407, 93, 130, 20);
						pnlPatientAppointments.add(cmbDay);
						
						cmbMonth = new JComboBox();
						cmbMonth.setBounds(407, 118, 130, 20);
						pnlPatientAppointments.add(cmbMonth);
						
						final JLabel label_13 = new JLabel("Day:");
						label_13.setBounds(366, 93, 46, 14);
						pnlPatientAppointments.add(label_13);
						
						final JLabel label_14 = new JLabel("Month:");
						label_14.setBounds(366, 118, 46, 14);
						pnlPatientAppointments.add(label_14);
						
						cmbYear = new JComboBox();
						cmbYear.setBounds(407, 144, 130, 20);
						pnlPatientAppointments.add(cmbYear);
						
						final JLabel label_15 = new JLabel("Year:");
						label_15.setBounds(366, 143, 46, 14);
						pnlPatientAppointments.add(label_15);
						
						final JLabel label_16 = new JLabel("hh:mm");
						label_16.setBounds(547, 64, 46, 14);
						pnlPatientAppointments.add(label_16);
						
						final JButton btnDelete = new JButton("Delete");
						btnDelete.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent arg0) {
								final Object[] appsToDel = lstAppointments.
									getSelectedValues();
								for(int i = 0; i < appsToDel.length; i++){
									((Appointment) (appsToDel[i])).destroy();
									appsPatient.remove(((Appointment)
											appsToDel[i]));
								}
								rebindApps();
							}
						});
						btnDelete.setBounds(10, 272, 89, 23);
						pnlPatientAppointments.add(btnDelete);
						
						JButton btnEdit = new JButton("Update");
						btnEdit.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent arg0) {
								
								Appointment newApp = (Appointment)lstAppointments.getSelectedValue();
								appsPatient.remove(newApp);
								
								
								newApp.setReason(tbReason.getText());
								
								
								newApp.setDesiredDoctor(((User)(cmbDoctor.getSelectedItem())).getUID());
								
								//create new date
								Calendar cal = Calendar.getInstance();
								int year = (Integer)(cmbYear.getSelectedItem()); 
								int day = (Integer)(cmbDay.getSelectedItem());
								String monthStr = (String)(cmbMonth.getSelectedItem());
								int monthInt = 0;
								for (int i = 0; i < monthsArray.length; i++){
									if (monthsArray[i].equalsIgnoreCase(monthStr)){
										monthInt = i;
										break;
									}
								}
								String[] time = tbHourMin.getText().split(":");
								int hour = Integer.parseInt(time[0]);
								int min = Integer.parseInt(time[1]);
								
								cal.set(year, monthInt, day, hour, min, 0);
								Date newDate = cal.getTime();						
								
								newApp.setDate(newDate);
								
								newApp.update();
								appsPatient.remove(newApp);
								resetNewAppFields();
								rebindApps();
							}
						});
						btnEdit.setBounds(464, 272, 75, 23);
						pnlPatientAppointments.add(btnEdit);
		
		pnlHistory = new JPanel();
		tabbedPane.addTab("Medical History", null, pnlHistory, null);
		pnlHistory.setLayout(null);
		
				final JLabel lblMyMedicalHistory =
					new JLabel("My Medical History:");
				lblMyMedicalHistory.setBounds(22, 11, 199, 14);
				pnlHistory.add(lblMyMedicalHistory);
				
						final JLabel lblNewLabel_2 =
							new JLabel("Treatment Records:");
						lblNewLabel_2.setBounds(22, 36, 199, 14);
						pnlHistory.add(lblNewLabel_2);
						
						lstMedical = new JList();
						lstMedical.addListSelectionListener(
								new ListSelectionListener() {
							public void valueChanged(ListSelectionEvent arg0) {
								bindTRInfo((TreatmentRecord)
										lstMedical.getModel().getElementAt(
												lstMedical.getSelectedIndex()));
							}
						});
						lstMedical.setBounds(22, 61, 227, 122);
						pnlHistory.add(lstMedical);
						
						final JLabel lblDoctorPrompt = new JLabel("Doctor:");
						lblDoctorPrompt.setBounds(298, 61, 76, 14);
						pnlHistory.add(lblDoctorPrompt);
						
						final JLabel lblNursePrompt = new JLabel("Nurse:");
						lblNursePrompt.setBounds(298, 96, 76, 14);
						pnlHistory.add(lblNursePrompt);
						
						final JLabel lblSymptomsPrompt = new JLabel("Symptoms:");
						lblSymptomsPrompt.setBounds(298, 132, 76, 14);
						pnlHistory.add(lblSymptomsPrompt);
						
						final JLabel lblDiagnosisl = new JLabel("Diagnosis:");
						lblDiagnosisl.setBounds(298, 169, 76, 14);
						pnlHistory.add(lblDiagnosisl);
						
						final JLabel lblBloodPressurePrompt =
							new JLabel("Blood Pressure:");
						lblBloodPressurePrompt.setBounds(50, 260, 96, 14);
						pnlHistory.add(lblBloodPressurePrompt);
						
						final JLabel lblPulsePrompt = new JLabel("Pulse:");
						lblPulsePrompt.setBounds(50, 288, 85, 14);
						pnlHistory.add(lblPulsePrompt);
						
						final JLabel lblTemperaturePrompt =
							new JLabel("Temperature:");
						lblTemperaturePrompt.setBounds(50, 313, 85, 14);
						pnlHistory.add(lblTemperaturePrompt);
						
						final JLabel lblHeightPrompt = new JLabel("Height:");
						lblHeightPrompt.setBounds(50, 338, 85, 14);
						pnlHistory.add(lblHeightPrompt);
						
						final JLabel lblWeightPrompt = new JLabel("Weight:");
						lblWeightPrompt.setBounds(50, 363, 85, 14);
						pnlHistory.add(lblWeightPrompt);
						
						final JLabel lblInstructionsPrompt =
							new JLabel("Instructions:");
						lblInstructionsPrompt.setBounds(325, 294, 85, 14);
						pnlHistory.add(lblInstructionsPrompt);
						
						final JLabel lblFollowUpPrompt = new JLabel("Follow up:");
						lblFollowUpPrompt.setBounds(51, 452, 85, 14);
						pnlHistory.add(lblFollowUpPrompt);
						
						final JLabel lblLabWorkPrompt = new JLabel("Procedure:");
						lblLabWorkPrompt.setBounds(51, 487, 85, 14);
						pnlHistory.add(lblLabWorkPrompt);
						
						final JLabel lblPrescription_1 =
							new JLabel("Prescription:");
						lblPrescription_1.setBounds(298, 235, 224, 14);
						pnlHistory.add(lblPrescription_1);
						
						final JButton btnGenerateInvoice =
							new JButton("Generate Invoice");
						btnGenerateInvoice.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent arg0) {
								final HashMap<String, Object> map =
									new HashMap<String, Object>();
								map.put("record", trs.toArray()[0]);
								map.put("filepath", "test.pdf");
								final PatientInvoice pi = new PatientInvoice();
								pi.generate(map);
								
							}
						});
						btnGenerateInvoice.setBounds(374, 481, 148, 23);
						pnlHistory.add(btnGenerateInvoice);
						
						final JLabel lblVitals = new JLabel("Vitals:");
						lblVitals.setBounds(22, 235, 85, 14);
						pnlHistory.add(lblVitals);
						
						final JLabel lblDoctorOrders =
							new JLabel("Doctor Orders:");
						lblDoctorOrders.setBounds(23, 396, 169, 14);
						pnlHistory.add(lblDoctorOrders);
						
						tbDrugname = new JTextField();
						tbDrugname.setEditable(false);
						tbDrugname.setBounds(405, 260, 117, 20);
						pnlHistory.add(tbDrugname);
						tbDrugname.setColumns(10);
						
						tbProcedure = new JTextField();
						tbProcedure.setEditable(false);
						tbProcedure.setColumns(10);
						tbProcedure.setBounds(146, 484, 170, 20);
						pnlHistory.add(tbProcedure);
						
						tbFollowup = new JTextField();
						tbFollowup.setEditable(false);
						tbFollowup.setColumns(10);
						tbFollowup.setBounds(146, 451, 170, 20);
						pnlHistory.add(tbFollowup);
						
						tbPreInstructions = new JTextField();
						tbPreInstructions.setEditable(false);
						tbPreInstructions.setColumns(10);
						tbPreInstructions.setBounds(405, 291, 117, 20);
						pnlHistory.add(tbPreInstructions);
						
						tbBloodpressure = new JTextField();
						tbBloodpressure.setEditable(false);
						tbBloodpressure.setColumns(10);
						tbBloodpressure.setBounds(145, 256, 104, 20);
						pnlHistory.add(tbBloodpressure);
						
						tbPulse = new JTextField();
						tbPulse.setEditable(false);
						tbPulse.setColumns(10);
						tbPulse.setBounds(145, 284, 104, 20);
						pnlHistory.add(tbPulse);
						
						tbTemp = new JTextField();
						tbTemp.setEditable(false);
						tbTemp.setColumns(10);
						tbTemp.setBounds(145, 309, 104, 20);
						pnlHistory.add(tbTemp);
						
						tbHeight = new JTextField();
						tbHeight.setEditable(false);
						tbHeight.setColumns(10);
						tbHeight.setBounds(145, 337, 104, 20);
						pnlHistory.add(tbHeight);
						
						tbWeight = new JTextField();
						tbWeight.setEditable(false);
						tbWeight.setColumns(10);
						tbWeight.setBounds(145, 362, 104, 20);
						pnlHistory.add(tbWeight);
						
						tbDoctor = new JTextField();
						tbDoctor.setEditable(false);
						tbDoctor.setColumns(10);
						tbDoctor.setBounds(374, 61, 148, 20);
						pnlHistory.add(tbDoctor);
						
						tbNurse = new JTextField();
						tbNurse.setEditable(false);
						tbNurse.setColumns(10);
						tbNurse.setBounds(374, 95, 148, 20);
						pnlHistory.add(tbNurse);
						
						tbSymptoms = new JTextField();
						tbSymptoms.setEditable(false);
						tbSymptoms.setColumns(10);
						tbSymptoms.setBounds(374, 131, 148, 20);
						pnlHistory.add(tbSymptoms);
						
						tbDiagnosis = new JTextField();
						tbDiagnosis.setEditable(false);
						tbDiagnosis.setColumns(10);
						tbDiagnosis.setBounds(374, 165, 148, 20);
						pnlHistory.add(tbDiagnosis);
						
						final JLabel lblDrugName = new JLabel("Drug Name:");
						lblDrugName.setBounds(325, 263, 85, 14);
						pnlHistory.add(lblDrugName);
						
						final JLabel label_1 = new JLabel("Instructions:");
						label_1.setBounds(51, 423, 85, 14);
						pnlHistory.add(label_1);
						
						tbInstructions = new JTextField();
						tbInstructions.setEditable(false);
						tbInstructions.setColumns(10);
						tbInstructions.setBounds(146, 423, 170, 20);
						pnlHistory.add(tbInstructions);
		
		pnlPatients = new JPanel();
		tabbedPane.addTab("Patients", null, pnlPatients, null);
		pnlPatients.setLayout(null);
		
		final JButton btnEditPatientDetails = new JButton("Edit Patient Details");
		btnEditPatientDetails.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				editPatient((Patient) lstPatients.getModel().
						getElementAt(lstPatients.getSelectedIndex()));
			}
		});
		btnEditPatientDetails.setBounds(25, 300, 202, 23);
		pnlPatients.add(btnEditPatientDetails);
		
		final JLabel lblNewLabel = new JLabel("Patient Name:");
		lblNewLabel.setBounds(25, 41, 120, 14);
		pnlPatients.add(lblNewLabel);
		
		tbSearch = new JTextField();
		tbSearch.setBounds(25, 66, 120, 20);
		pnlPatients.add(tbSearch);
		tbSearch.setColumns(10);
		
		lstPatients = new JList();
		lstPatients.addListSelectionListener(new ListSelectionListener() {

			public void valueChanged(ListSelectionEvent arg0) {
				//load treatment records
				if(lstPatients.getSelectedIndex() >= 0){
					final Patient selectedPatient =
						(Patient) lstPatients.getModel().
						getElementAt(lstPatients.getSelectedIndex());
					loadTRs(selectedPatient);
					
					loadChartPanel(selectedPatient);
				}
			}
		});
		lstPatients.setBounds(25, 97, 202, 192);
		pnlPatients.add(lstPatients);
		
		final JButton btnAddTreatmetnRecord = new JButton("Add Treatment Record");
		btnAddTreatmetnRecord.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				createTR((Patient) lstPatients.getModel().
						getElementAt(lstPatients.getSelectedIndex()));
			}
		});
		btnAddTreatmetnRecord.setBounds(25, 334, 202, 23);
		pnlPatients.add(btnAddTreatmetnRecord);
		
		final JButton btnEditTreatmentRecord =
			new JButton("Edit Treatment Record");
		btnEditTreatmentRecord.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				updateTR((Patient) lstPatients.getModel().
						getElementAt(lstPatients.getSelectedIndex()),
						(TreatmentRecord) lstTRs.getModel().
						getElementAt(lstTRs.getSelectedIndex()));
			}
		});
		btnEditTreatmentRecord.setBounds(25, 450, 202, 23);
		pnlPatients.add(btnEditTreatmentRecord);
		
		lstTRs = new JList();
		lstTRs.setBounds(25, 368, 202, 71);
		pnlPatients.add(lstTRs);
		
		final JButton btnSearch = new JButton("Search");
		btnSearch.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				search(tbSearch.getText());
			}
		});
		btnSearch.setBounds(237, 65, 110, 23);
		pnlPatients.add(btnSearch);
		
		final JButton btnClearSearch = new JButton("Clear Search");
		btnClearSearch.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				clearSearch();
			}
		});
		btnClearSearch.setBounds(237, 94, 110, 23);
		pnlPatients.add(btnClearSearch);
		
		//JFreeChartPanel 
		this.chartPanel = new ImagePanel();
		this.chartPanel.setBounds(249, 140, 344, 284);
		pnlPatients.add(chartPanel);
		
		panel = new JPanel();
		tabbedPane.addTab("Appointments", null, panel, null);
		panel.setLayout(null);
		
		final JLabel lblNewLabel_1 = new JLabel("Appointments for Today:");
		lblNewLabel_1.setBounds(10, 11, 237, 14);
		panel.add(lblNewLabel_1);
		
		lstAppointments2 = new JList();
		lstAppointments2.addListSelectionListener(new ListSelectionListener() {
			public void valueChanged(ListSelectionEvent arg0) {
				final User u = Patient.loadUserFromPatient((((Appointment) 
						lstAppointments2.getSelectedValue()).getPatient()));
				tbFirst2.setText(u.getFirstName());
				tbLast2.setText(u.getLastName());
				tbReason2.setText(((Appointment) lstAppointments2.
						getSelectedValue()).getReason());
				tbDoctor2.setText(User.lookupUser(((Appointment)
						lstAppointments2.getSelectedValue()).getDesiredDoctor()).
						toString());
			}
		});
		lstAppointments2.setBounds(10, 36, 319, 451);
		panel.add(lstAppointments2);
		
		final JLabel lblAppointmentDetails = new JLabel("Appointment Details:");
		lblAppointmentDetails.setBounds(377, 11, 187, 14);
		panel.add(lblAppointmentDetails);
		
		final JLabel lblName = new JLabel("First:");
		lblName.setBounds(377, 36, 46, 14);
		panel.add(lblName);
		
		tbFirst2 = new JTextField();
		tbFirst2.setEditable(false);
		tbFirst2.setColumns(10);
		tbFirst2.setBounds(418, 36, 130, 20);
		panel.add(tbFirst2);
		
		final JLabel lblLast = new JLabel("Last:");
		lblLast.setBounds(376, 61, 46, 14);
		panel.add(lblLast);
		
		tbLast2 = new JTextField();
		tbLast2.setEditable(false);
		tbLast2.setBounds(418, 61, 130, 20);
		panel.add(tbLast2);
		tbLast2.setColumns(10);
		
		final JLabel label = new JLabel("Desired Doctor:");
		label.setBounds(376, 86, 172, 14);
		panel.add(label);
		
		final JLabel label_6 = new JLabel("Reason for Appointment:");
		label_6.setBounds(376, 131, 170, 14);
		panel.add(label_6);
		
		tbReason2 = new JTextField();
		tbReason2.setEditable(false);
		tbReason2.setColumns(10);
		tbReason2.setBounds(376, 149, 172, 20);
		panel.add(tbReason2);
		
		tbDoctor2 = new JTextField();
		tbDoctor2.setEditable(false);
		tbDoctor2.setColumns(10);
		tbDoctor2.setBounds(376, 100, 172, 20);
		panel.add(tbDoctor2);
		
		pnlReports = new JPanel();
		tabbedPane.addTab("Reports", null, pnlReports, null);
		pnlReports.setLayout(null);
		
		final JLabel lblReports = new JLabel("Reports:");
		lblReports.setBounds(10, 11, 77, 14);
		pnlReports.add(lblReports);
		
		final JLabel lblPatientHealthHistory =
			new JLabel("Patient Health History");
		lblPatientHealthHistory.setBounds(10, 36, 172, 14);
		pnlReports.add(lblPatientHealthHistory);
		
		final JLabel lblIncomeStatement = new JLabel("Income Statement:");
		lblIncomeStatement.setBounds(10, 277, 127, 14);
		pnlReports.add(lblIncomeStatement);
		
		final JList list_3 = new JList();
		list_3.setBounds(10, 61, 201, 145);
		pnlReports.add(list_3);
		
		final JButton btnGenerateHealthHistory =
			new JButton("Generate Health History Report");
		btnGenerateHealthHistory.setBounds(10, 217, 201, 23);
		pnlReports.add(btnGenerateHealthHistory);
		
		final JLabel lblMonth = new JLabel("Month:");
		lblMonth.setBounds(10, 302, 46, 14);
		pnlReports.add(lblMonth);
		
		tbMonth = new JTextField();
		tbMonth.setBounds(66, 299, 145, 20);
		pnlReports.add(tbMonth);
		tbMonth.setColumns(10);
		
		final JButton btnGenerateIncomeStatement =
			new JButton("Generate Income Statement");
		btnGenerateIncomeStatement.setBounds(10, 336, 201, 23);
		pnlReports.add(btnGenerateIncomeStatement);
		
		pnlUsers = new JPanel();
		tabbedPane.addTab("Users", null, pnlUsers, null);
		pnlUsers.setLayout(null);
		
		final JLabel lblEditUsers = new JLabel("Edit Users:");
		lblEditUsers.setBounds(10, 11, 76, 14);
		pnlUsers.add(lblEditUsers);
		
		final JLabel lblFirstName = new JLabel("First Name:");
		lblFirstName.setBounds(10, 331, 76, 14);
		pnlUsers.add(lblFirstName);
		
		tbFirst = new JTextField();
		tbFirst.setColumns(10);
		tbFirst.setBounds(122, 331, 130, 20);
		pnlUsers.add(tbFirst);
		
		final JLabel lblLastName = new JLabel("Last Name:");
		lblLastName.setBounds(10, 356, 76, 14);
		pnlUsers.add(lblLastName);
		
		tbLast = new JTextField();
		tbLast.setColumns(10);
		tbLast.setBounds(122, 356, 130, 20);
		pnlUsers.add(tbLast);
		
		tbUsername = new JTextField();
		tbUsername.setColumns(10);
		tbUsername.setBounds(122, 381, 130, 20);
		pnlUsers.add(tbUsername);
		
		final JLabel lblUsername = new JLabel("Username:");
		lblUsername.setBounds(10, 381, 59, 14);
		pnlUsers.add(lblUsername);
		
		final JLabel lblPassword = new JLabel("Password:");
		lblPassword.setBounds(10, 406, 59, 14);
		pnlUsers.add(lblPassword);
		
		tbPassword = new JTextField();
		tbPassword.setColumns(10);
		tbPassword.setBounds(122, 406, 130, 20);
		pnlUsers.add(tbPassword);
		
		final JLabel lblUserType = new JLabel("User Type:");
		lblUserType.setBounds(10, 431, 85, 14);
		pnlUsers.add(lblUserType);
		
		cbUserType = new JComboBox();
		cbUserType.setModel(new DefaultComboBoxModel(
				new String[] {"Patient", "Nurse",
						"Doctor", "System Administrator"}));
		cbUserType.setBounds(122, 434, 130, 20);
		pnlUsers.add(cbUserType);
		
		final JButton btnSaveChanges = new JButton("Save Changes");
		btnSaveChanges.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				if(lstUsers.getSelectedIndex() >= 0) {
					updateUser((User) lstUsers.getModel().
							getElementAt(lstUsers.getSelectedIndex()));
					rebind();
				}
			}
		});
		btnSaveChanges.setBounds(122, 461, 130, 23);
		pnlUsers.add(btnSaveChanges);
		
		final JButton btnSuspendUser = new JButton("Suspend User");
		btnSuspendUser.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				final User user = ((User) lstUsers.getModel().
						getElementAt(lstUsers.getSelectedIndex()));
				user.suspend();
				//
			}
		});
		btnSuspendUser.setBounds(250, 234, 121, 23);
		pnlUsers.add(btnSuspendUser);
		
		final JButton btnUnsuspendUser = new JButton("Unsuspend User");
		btnUnsuspendUser.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			final User user = ((User) lstUsers.getModel().
					getElementAt(lstUsers.getSelectedIndex()));
			user.unsuspend();
			}
		});
		btnUnsuspendUser.setBounds(250, 258, 121, 23);
		pnlUsers.add(btnUnsuspendUser);
		
		final JButton btnDeleteUser = new JButton("Delete User");
		btnDeleteUser.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				deleteUser((User) lstUsers.getModel().
						getElementAt(lstUsers.getSelectedIndex()));
				rebind();
			}
		});
		btnDeleteUser.setBounds(250, 211, 121, 23);
		pnlUsers.add(btnDeleteUser);
		
		final JButton btnAddUser = new JButton("Add User");
		btnAddUser.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				addUser();
			}
		});
		btnAddUser.setBounds(250, 187, 121, 23);
		pnlUsers.add(btnAddUser);
		
		final JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(10, 50, 182, 230);
		
		lstUsers = new JList();
		lstUsers.addListSelectionListener(new ListSelectionListener() {
			public void valueChanged(ListSelectionEvent arg0) {
				if(!deletingUser && lstUsers.getSelectedIndex() >= 0 ){
					bindUser((User) lstUsers.getModel().
							getElementAt(lstUsers.getSelectedIndex()));
				}
			}
		});
		lstUsers.setBounds(10, 36, 230, 284);
		
		lstUsers.setVisibleRowCount(5);
		scrollPane.setViewportView(lstUsers);
		pnlUsers.add(scrollPane);
		initDataBindings();

		if(loggedUser.getUsertype().equalsIgnoreCase("p")) {
			tabbedPane.removeTabAt(2);
			tabbedPane.removeTabAt(2);
			tabbedPane.removeTabAt(2);
			tabbedPane.removeTabAt(2);
		}
		else if(loggedUser.getUsertype().equalsIgnoreCase("n")) {
			tabbedPane.removeTabAt(5);
			tabbedPane.removeTabAt(4);
			tabbedPane.removeTabAt(0);
			tabbedPane.removeTabAt(0);
		}
		else if(loggedUser.getUsertype().equalsIgnoreCase("d")) {
			tabbedPane.removeTabAt(5);
			tabbedPane.removeTabAt(0);
			tabbedPane.removeTabAt(0);
		}
		else if(loggedUser.getUsertype().equalsIgnoreCase("a")) {
			tabbedPane.removeTabAt(0);
			tabbedPane.removeTabAt(0);
		}
	}


	
	/**
	 * Method loadTRs.
	 * @param patient Patient
	 */
	private void loadTRs(Patient patient) {
		final List<TreatmentRecord> trs = TreatmentRecord.
			getTreatmentRecords(patient.getPatientID());
		final JListBinding<TreatmentRecord,
			List<TreatmentRecord>, JList> jListBinding = 
			SwingBindings.createJListBinding(UpdateStrategy.READ, trs, lstTRs);
		jListBinding.bind();
	
		
	}

	/**
	 * Method createTR.
	 * @param patient Patient
	 */
	private void createTR(Patient patient) {
		final TRFrame frame = new TRFrame(this, patient);
		setVisible(false);
		frame.setVisible(true);
	}
	/**
	 * Method updateTR.
	 * @param patient Patient
	 * @param treatmentRecord TreatmentRecord
	 */
	private void updateTR(Patient patient, TreatmentRecord treatmentRecord) {
		final TRFrame frame = new TRFrame(this, patient, treatmentRecord);
		setVisible(false);
		frame.setVisible(true);
	}
	/**
	 * Method editPatient.
	 * @param patient Patient
	 */
	private void editPatient(Patient patient) {
		final EditPatientFrame frame = new EditPatientFrame(this, patient);
		setVisible(false);
		frame.setVisible(true);
	}
	
	/**
	 * Panel used to display the PatientHealthHistory report when you
	 * click on a patient.  
	 * @author William Barr
	 *
	 */
	private class ImagePanel extends JPanel {
		
		/**
		 * Field image.
		 */
		private Image image;
		
		/**
		 * Constructor for ImagePanel.
		 */
		public ImagePanel(){ // $codepro.audit.disable publicConstructorInNonPublicType
			image = null;
		}
		
		/**
		 * Change the image you want this ImagePanel to display.  
		 * @param img The chart image you wish to display.  
		 */
		public void setImage(Image img){
			this.image = img;
			final Dimension dims = new Dimension(image.getWidth(null),
					image.getHeight(null));
			setPreferredSize(dims);
			setMinimumSize(dims);
			setMaximumSize(dims);
			setSize(dims);
			setLayout(null);
			this.repaint();
		}
		
		/**
		 * Method paintComponent.
		 * @param panelGraphics Graphics
		 */
		public void paintComponent(Graphics panelGraphics){
			if(this.image != null){
				panelGraphics.drawImage(this.image, 0, 0, null); // $codepro.audit.disable com.instantiations.assist.eclipse.analysis.unusedReturnValue -->
			}
		}
	}
	
	/**
	 * Builds a PatientHealthHistory chart and displays it in the chartPanel.  
	 * @param selectedPatient The patient you want to display the chart for.  
	 */
	private void loadChartPanel(Patient selectedPatient) {
		//Generate chart
		final HashMap<String, Object> params = new HashMap<String, Object>(); // $codepro.audit.disable declareAsInterface -->
		params.put("patient", selectedPatient);
		final PatientChart theChart = new PatientChart();
		theChart.generate(params);
		
		chartPanel.setImage(new ImageIcon("healthreport.jpg").getImage());
		chartPanel.repaint();
	}
	
	/**
	 * Method bindTRInfo.
	 * @param tr TreatmentRecord
	 */
	private void bindTRInfo(TreatmentRecord tr) {
		//SimpleDateFormat sdf = new SimpleDateFormat();
		//lblTime.setText(sdf.format(tr.getDate()));
		tbDoctor.setText(tr.getDoctorName());
		tbNurse.setText(tr.getNurseName());
		tbSymptoms.setText(tr.getSymptoms());
		tbDiagnosis.setText(tr.getDiagnosis());
		tbBloodpressure.setText(new Integer(tr.getVitalSigns().getBloodPressure()).
				toString());
		tbPulse.setText(new Integer(tr.getVitalSigns().getPulse()).toString());
		tbTemp.setText(new Double(tr.getVitalSigns().getTemp()).toString());
		tbHeight.setText(new Double(tr.getVitalSigns().getHeight()).toString());
		tbWeight.setText(new Double(tr.getVitalSigns().getWeight()).toString());
		final DoctorsOrders drOrders= (DoctorsOrders)
			(DoctorsOrders.getDrsOrders(tr.getDoctorsOrders()).toArray()[0]);
		
		tbInstructions.setText(drOrders.getInstructions());
		tbFollowup.setText(drOrders.getFollowUpInstructions());
		tbProcedure.setText(drOrders.getProcedures()[0].getProcedureName());
		tbPreInstructions.setText(drOrders.getPrescriptions()[0].
				getInstructions());
		tbDrugname.setText(drOrders.getPrescriptions()[0].getDrugName());
		//DoctorsOrders.getDrsOrders(tr.getDoctorsOrders())
		
		//lblPerscription.setText(tr.getDoctorsOrders(tr.getDoctorsOrders()).getPrescriptions());
		
		//Patient patient = tr.getPatient();
		
		//lblFirst.setText(patient.getFirstName());
		//lblLast.setText(patient.getLastName());
	}
	/**
	 * Method bindUser.
	 * @param user User
	 */
	private void bindUser(User user) {
		tbFirst.setText(user.getFirstName());
		tbLast.setText(user.getLastName());
		tbUsername.setText(user.getUsername());
		tbPassword.setText(user.getPassword());
		
		final String userType = user.getUsertype();
		if(userType.equalsIgnoreCase("p")) {
			cbUserType.setSelectedIndex(0);
		}
		else if(userType.equalsIgnoreCase("n")) {
			cbUserType.setSelectedIndex(1);
		}
		else if(userType.equalsIgnoreCase("d")) {
			cbUserType.setSelectedIndex(2);
		}
		else if(userType.equalsIgnoreCase("a")) {
			cbUserType.setSelectedIndex(3);
		}
	}
	
	/**
	 * Method updateUser.
	 * @param user User
	 */
	private void updateUser(User user) {
		user.setFirstName(tbFirst.getText());
		user.setLastName(tbLast.getText());
		user.setUsername(tbUsername.getText());
		user.setPassword(tbPassword.getText());
		
		if(cbUserType.getSelectedIndex() == 0) {
			user.setUsertype("p");
		}
		else if(cbUserType.getSelectedIndex() == 1) {
			user.setUsertype("n");
		}
		else if(cbUserType.getSelectedIndex() == 2) {
			user.setUsertype("d");
		}
		else if(cbUserType.getSelectedIndex() == 3) {
			user.setUsertype("a");
		}
		
		user.update();
		rebindUsers(); //---CHECKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
		
	}
	
	/**
	 * Field deletingUser.
	 */
	boolean deletingUser = false;
	/**
	 * Field tbFirst2.
	 */
	private JTextField tbFirst2;
	/**
	 * Field tbLast2.
	 */
	private JTextField tbLast2;
	/**
	 * Field tbReason2.
	 */
	private JTextField tbReason2;
	/**
	 * Field tbDoctor2.
	 */
	private JTextField tbDoctor2;
	/**
	 * Field tbDrugname.
	 */
	private JTextField tbDrugname;
	/**
	 * Field tbProcedure.
	 */
	private JTextField tbProcedure;
	/**
	 * Field tbFollowup.
	 */
	private JTextField tbFollowup;
	/**
	 * Field tbPreInstructions.
	 */
	private JTextField tbPreInstructions;
	/**
	 * Field tbBloodpressure.
	 */
	private JTextField tbBloodpressure;
	/**
	 * Field tbPulse.
	 */
	private JTextField tbPulse;
	/**
	 * Field tbTemp.
	 */
	private JTextField tbTemp;
	/**
	 * Field tbHeight.
	 */
	private JTextField tbHeight;
	/**
	 * Field tbWeight.
	 */
	private JTextField tbWeight;
	/**
	 * Field tbDoctor.
	 */
	private JTextField tbDoctor;
	/**
	 * Field tbNurse.
	 */
	private JTextField tbNurse;
	/**
	 * Field tbSymptoms.
	 */
	private JTextField tbSymptoms;
	/**
	 * Field tbDiagnosis.
	 */
	private JTextField tbDiagnosis;
	/**
	 * Field tbInstructions.
	 */
	private JTextField tbInstructions;
	/**
	 * Method deleteUser.
	 * @param user User
	 */
	private void deleteUser(User user) {
		deletingUser = true;
		users.remove(user);
		user.destroy();
		rebindUsers();
		deletingUser = false;
	}
	/**
	 * Method addUser.
	 */
	private void addUser() {
		final AddUserFrame wnd = new AddUserFrame(this);
		wnd.setVisible(true);
		setVisible(false);
	}
	
	/**
	 * Method rebind.
	 */
	public void rebind() {
		setDefaultValues();
		initDataBindings();
	}
	/**
	 * Method rebindPatients.
	 */
	private void rebindPatients() {
		final JListBinding<Patient, List<Patient>, JList> jListBinding =
			SwingBindings.createJListBinding(UpdateStrategy.READ, patients,
					lstPatients);
		jListBinding.bind();
	}
	/**
	 * Method rebindTRs.
	 */
	public void rebindTRs() {
		loadTRs((Patient) lstPatients.getModel().getElementAt(lstPatients.
				getSelectedIndex()));
	}
	/**
	 * Method rebindUsers.
	 */
	public void rebindUsers() {
		final JListBinding<User, List<User>, JList> jListBinding_3 = 
			SwingBindings.createJListBinding(UpdateStrategy.READ, users,
					lstUsers);
		jListBinding_3.bind();
	}
	/**
	 * Method rebindUsers.
	 * @param user User
	 */
	public void rebindUsers(User user) {
		users.add(user);
		rebindUsers();
	}
	/**
	 * Method rebindApps.
	 */
	public void rebindApps(){
		final JListBinding<Appointment, List<Appointment>, JList> jListBinding_1 =
			SwingBindings.createJListBinding(UpdateStrategy.READ, appsPatient,
					lstAppointments);
		jListBinding_1.bind();
		final JListBinding<Appointment, List<Appointment>, JList> jListBinding_2 =
			SwingBindings.createJListBinding(UpdateStrategy.READ, apps,
					lstAppointments2);
		jListBinding_2.bind();
	}
	/**
	 * Method search.
	 * @param text String
	 */
	private void search(String text) {
		String first = "";
		String last = "";
		if(!text.contains(" ")) {
			first = text;
		}
		else {
			final String[] parts = text.split(" ");
			first = parts[0];
			last = parts[1];
		}
		patients = Patient.lookupPatients(first, last);
		rebindPatients();
	}
	/**
	 * Method clearSearch.
	 */
	private void clearSearch() {
		patients = Patient.lookupAllPatients();
		rebindPatients();
	}
	/**
	 * Method resetNewAppFields.
	 */
	public void resetNewAppFields() {
		tbHourMin.setText("");
		tbReason.setText("");
		cmbDay.setSelectedIndex(0);
		cmbMonth.setSelectedIndex(0);
		cmbYear.setSelectedIndex(0);
		cmbDoctor.setSelectedIndex(0);
	}
	/**
	 * Method initDataBindings.
	 */
	protected void initDataBindings() {
		final JListBinding<Patient, List<Patient>, JList> jListBinding =
			SwingBindings.createJListBinding(UpdateStrategy.READ, patients,
					lstPatients);
		jListBinding.bind();
		//
		final JListBinding<Appointment, List<Appointment>, JList> jListBinding_1 =
			SwingBindings.createJListBinding(UpdateStrategy.READ, appsPatient,
					lstAppointments);
		jListBinding_1.bind();
		
		final JListBinding<Appointment, List<Appointment>, JList> jListBinding_12 =
			SwingBindings.createJListBinding(UpdateStrategy.READ, apps,
					lstAppointments2);
		jListBinding_12.bind();
		
		final JListBinding<TreatmentRecord, List<TreatmentRecord>, JList>
			jListBinding_2 = SwingBindings.createJListBinding(
					UpdateStrategy.READ, trs, lstMedical);
		jListBinding_2.bind();
		
		final JComboBoxBinding<User, List<User>, JComboBox> jComboBinding =
			SwingBindings.createJComboBoxBinding(UpdateStrategy.READ, doctors,
					cmbDoctor, "cmbBinding");
		jComboBinding.bind();
		
		final JListBinding<User, List<User>, JList> jListBinding_3 =
			SwingBindings.createJListBinding(UpdateStrategy.READ, users,
					lstUsers);
		jListBinding_3.bind();
		final JComboBoxBinding<Integer, List<Integer>, JComboBox> jComboBinding2 =
			SwingBindings.createJComboBoxBinding(UpdateStrategy.READ, day, cmbDay,
					"cmbBinding");
		jComboBinding2.bind();
		
		final JComboBoxBinding<String, List<String>, JComboBox> jComboBinding3 =
			SwingBindings.createJComboBoxBinding(UpdateStrategy.READ, months,
					cmbMonth, "cmbBinding");
		jComboBinding3.bind();
		
		final JComboBoxBinding<Integer, List<Integer>, JComboBox> jComboBinding4 =
			SwingBindings.createJComboBoxBinding(UpdateStrategy.READ, year,
					cmbYear, "cmbBinding");
		jComboBinding4.bind();
	}
	/**
	 * Method getUser.
	 * @return User
	 */
	public User getUser(){
		return user;
	}
}
